package com.yuwj.chinaa.view;

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.yuwj.chinaa.R;


public class DownloadFileProgressDialog extends Dialog {


    private Context context;
    BroadcastReceiver updateProgressBroadcastReceiver;//更新进度条广播接收器
    private CustomProgressDialogClickListener customProgressDialogClickListener;
    TextView tv_download_percent;
    ProgressBar pb_download_percent;
    TextView tv_stop_download;
    boolean isRegistBroadcast;

    public interface CustomProgressDialogClickListener {
        public void doCancelDownload(DownloadFileProgressDialog dialog);
    }

    public DownloadFileProgressDialog(Context context) {
        super(context, R.style.style_download_file_customDialog);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
    }

    public void initView() {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater
                .inflate(R.layout.content_checkupdate_downloadfile_progress, null);
        setContentView(view);

        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
        lp.width = (int) (d.widthPixels * 0.4); // 高度设置为屏幕的0.8
        lp.height = (int) (d.heightPixels * 0.3);// 宽度设置为屏幕高度的0.6
        dialogWindow.setAttributes(lp);
        setCanceledOnTouchOutside(false);
    }
}